//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public License
// along with this program.  If not, see http://www.gnu.org/licenses/.
// 

#ifndef EXTANDROIDCLIENT_H_
#define EXTANDROIDCLIENT_H_

#include <platdep/sockets.h>
#include <omnetpp.h>
#include "TelnetPkt_m.h"
#include "cSocketRTScheduler.h"

class ExtAndroidClient  : public cSimpleModule
{
private:
    cMessage *rtEvent;
    cSocketRTScheduler *rtScheduler;

    int addr;
    int srvAddr;

    //int               MAX_BUFFER_LENGTH=4000;
    int               c_nTotalBytes;
    int               c_nSentBytes;
    SOCKET            c_socket;
    char              c_buffer[4000];

public:
    ExtAndroidClient();
    virtual ~ExtAndroidClient();

public:
    virtual void initialize();
    virtual void handleMessage(cMessage *msg);
    void handleSocketEvent();
    void handleReply(TelnetPkt *telnetReply);

    void        setRtEvent(cMessage*);
    cMessage*   getRtEvent();

    void    setSocket(SOCKET socketFd);
    SOCKET  getSocket();
    void    closeSocket();

    void    setTotalBytes(int n);
    int     getTotalBytes();

    void    setSentBytes(int n);
    void    incSentBytes(int n);
    int     getSentBytes();

    void    setBuffer(char *buffer);
    void    getBuffer(char *buffer);
    char*   getBuffer();
    void    zeroBuffer();
};

#endif /* EXTANDROIDCLIENT_H_ */
